<template>
  <div class="comp lowcode">
    <div class="left">
      <router-link to="/home">首页</router-link>
      <router-link to="/editpage">编辑页面</router-link>
    </div>
    <div class="right">
      <!-- <textlabel /> -->
      <div class="p-item" v-for="item of compList" :key="item">
        <div class="comp">
          <component :is="item" :id="item" />
        </div>
        <el-button type="primary" @click="outPicture(item)">导出图片</el-button>
      </div>
      <div class="p-item">
        <div class="comp">
          <Bar id="bar" />
        </div>
        <el-button type="primary" @click="outPicture('bar')"
          >导出图片</el-button
        >
      </div>
      <div class="p-item">
        <div class="comp">
          <!-- <Line id="line" /> -->
          <!-- <component :is="Text" /> -->
          <Text id="line" />
        </div>
        <el-button type="primary" @click="outPicture('line')"
          >导出图片</el-button
        >
      </div>
      <img src="../../assets/images/chart/charts/bar_x.png" alt="" />
    </div>
  </div>
</template>

<script setup>
import { ElMessage } from "element-plus"
import { canvasCut } from "@/utils/utils"
import Bar from "@/packages/components/Charts/Bars/BarCommon/index.vue"
import BarCrossrange from "@/packages/components/Charts/Bars/BarCrossrange/index.vue"
import Line from "@/packages/components/Charts/Lines/LineCommon/index.vue"
import Text from "@/packages/components/Card/Text/TextCommon/index.vue"

let compList = ["textlabel", "comp2", "comp3"]

function outPicture(id) {
  let el = document.body.querySelector(`#${id}`)
  if (!el) {
    ElMessage.warning("未找到元素")
    return
  }
  canvasCut(el)
}
</script>

<style scoped lang="scss">
.comp {
  width: 100%;
  height: 100%;
  display: flex;
  .left {
    width: 20%;
    height: 100%;
    background-color: #999;
  }
  .right {
    flex: 1;

    .p-item {
      display: flex;
      .comp {
        width: 80px;
        height: 80px;
        margin-right: 20px;
      }
    }
  }
}
</style>
